{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 61,
   "outputs": [],
   "source": [
    "import pandas as pd"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "outputs": [
    {
     "data": {
      "text/plain": "          货号  商品代码  颜色代码  商品名称 品牌   成本  季节  商品年份\n0   QTVW5600  QTVW  5600   羽绒服  A  180  冬季  2018\n1   AXTB3200  AXTB  3200    棉服  B   90  冬季  2019\n2   VBOY1800  VBOY  1800   家居服  C  120  冬季  2018\n3   HWLA4700  HWLA  4700  长袖T恤  A   30  秋季  2020\n4   XDQV5600  XDQV  5600    卫衣  B   56  春季  2019\n5   XHQA3700  XHQA  3700  羊毛大衣  C  200  冬季  2018\n6   UQNA9200  UQNA  9200    毛衣  B   68  春季  2020\n7   FLHR1800  FLHR  1800  短袖T恤  A   25  夏季  2019\n8   LCHM9800  LCHM  9800  保暖内衣  B   50  冬季  2018\n9   AGDH5500  AGDH  5500   牛仔裤  C   80  四季  2019\n10  YZFM1200  YZFM  1200    夹克  B   70  秋季  2019\n11  PWDK9200  PWDK  9200  运动长裤  B   60  四季  2020",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>货号</th>\n      <th>商品代码</th>\n      <th>颜色代码</th>\n      <th>商品名称</th>\n      <th>品牌</th>\n      <th>成本</th>\n      <th>季节</th>\n      <th>商品年份</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>QTVW5600</td>\n      <td>QTVW</td>\n      <td>5600</td>\n      <td>羽绒服</td>\n      <td>A</td>\n      <td>180</td>\n      <td>冬季</td>\n      <td>2018</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>AXTB3200</td>\n      <td>AXTB</td>\n      <td>3200</td>\n      <td>棉服</td>\n      <td>B</td>\n      <td>90</td>\n      <td>冬季</td>\n      <td>2019</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>VBOY1800</td>\n      <td>VBOY</td>\n      <td>1800</td>\n      <td>家居服</td>\n      <td>C</td>\n      <td>120</td>\n      <td>冬季</td>\n      <td>2018</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>HWLA4700</td>\n      <td>HWLA</td>\n      <td>4700</td>\n      <td>长袖T恤</td>\n      <td>A</td>\n      <td>30</td>\n      <td>秋季</td>\n      <td>2020</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>XDQV5600</td>\n      <td>XDQV</td>\n      <td>5600</td>\n      <td>卫衣</td>\n      <td>B</td>\n      <td>56</td>\n      <td>春季</td>\n      <td>2019</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>XHQA3700</td>\n      <td>XHQA</td>\n      <td>3700</td>\n      <td>羊毛大衣</td>\n      <td>C</td>\n      <td>200</td>\n      <td>冬季</td>\n      <td>2018</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>UQNA9200</td>\n      <td>UQNA</td>\n      <td>9200</td>\n      <td>毛衣</td>\n      <td>B</td>\n      <td>68</td>\n      <td>春季</td>\n      <td>2020</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>FLHR1800</td>\n      <td>FLHR</td>\n      <td>1800</td>\n      <td>短袖T恤</td>\n      <td>A</td>\n      <td>25</td>\n      <td>夏季</td>\n      <td>2019</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>LCHM9800</td>\n      <td>LCHM</td>\n      <td>9800</td>\n      <td>保暖内衣</td>\n      <td>B</td>\n      <td>50</td>\n      <td>冬季</td>\n      <td>2018</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>AGDH5500</td>\n      <td>AGDH</td>\n      <td>5500</td>\n      <td>牛仔裤</td>\n      <td>C</td>\n      <td>80</td>\n      <td>四季</td>\n      <td>2019</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>YZFM1200</td>\n      <td>YZFM</td>\n      <td>1200</td>\n      <td>夹克</td>\n      <td>B</td>\n      <td>70</td>\n      <td>秋季</td>\n      <td>2019</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>PWDK9200</td>\n      <td>PWDK</td>\n      <td>9200</td>\n      <td>运动长裤</td>\n      <td>B</td>\n      <td>60</td>\n      <td>四季</td>\n      <td>2020</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 62
    }
   ],
   "source": [
    "df = pd.read_excel('goods_base.xlsx')\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "outputs": [
    {
     "data": {
      "text/plain": "货号      object\n商品代码    object\n颜色代码     int64\n商品名称    object\n品牌      object\n成本       int64\n季节      object\n商品年份     int64\ndtype: object"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 63
    }
   ],
   "source": [
    "df.dtypes"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "outputs": [
    {
     "data": {
      "text/plain": "货号        object\n商品代码      object\n颜色代码      object\n商品名称      object\n品牌      category\n成本         int64\n季节      category\n商品年份       int64\ndtype: object"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 64
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'goods_base.xlsx',\n",
    "    dtype={\n",
    "        '货号': 'str',\n",
    "        '商品代码': 'str',\n",
    "        '颜色代码': 'str',\n",
    "        '季节': 'category',\n",
    "        '品牌': 'category',\n",
    "        # '商品年份': 'period[Y]'\n",
    "    }\n",
    ")\n",
    "# 转化为str,再转化为string\n",
    "# df['颜色代码'] = df['颜色代码'].astype('string')\n",
    "df.dtypes\n",
    "\n",
    "\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}